/**
 * 
 */
package com.yidu.drug.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.drug.common.Tools;
import com.yidu.drug.dao.WholesaleModelMapper;
import com.yidu.drug.model.WholesaleModel;
import com.yidu.drug.service.WholesaleService;

/**
 * 类的描述
 * @author yuanqing
 * @date 2018年8月16日上午10:47:17
 * @version 1.0
 */
@Service
public class WholesaleServiceImpl implements WholesaleService{
	@Resource
	private WholesaleModelMapper wholesaleDao;

	@Override
	public int deleteByPrimaryKey(String pfId) {
		// TODO Auto-generated method stub
		return wholesaleDao.deleteByPrimaryKey(pfId);
	}

	@Override
	public int insert(WholesaleModel record) {
		// TODO Auto-generated method stub
		return wholesaleDao.insert(record);
	}

	@Override
	public int insertSelective(WholesaleModel record) {
		// TODO Auto-generated method stub
		return wholesaleDao.insertSelective(record);
	}

	@Override
	public WholesaleModel selectByPrimaryKey(String pfId) {
		// TODO Auto-generated method stub
		return wholesaleDao.selectByPrimaryKey(pfId);
	}

	@Override
	public int updateByPrimaryKeySelective(WholesaleModel record) {
		// TODO Auto-generated method stub
		return wholesaleDao.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKey(WholesaleModel record) {
		// TODO Auto-generated method stub
		return wholesaleDao.updateByPrimaryKey(record);
	}

	@Override
	public int findTotalRows(Map<String, String> map) {
		// TODO Auto-generated method stub
		return wholesaleDao.findTotalRows(map);
	}

	@Override
	public List<WholesaleModel> findAllPage(Map<String, String> paramMap) {
		List<WholesaleModel> list=wholesaleDao.findAllPage(paramMap);
		for(WholesaleModel wm:list){
			if(wm.getIsva().equals("1")){
				wm.setState("等待审核");
			}else if(wm.getIsva().equals("2")){
				wm.setState("审核通过");
			}else if(wm.getIsva().equals("0")){
				wm.setState("审核不通过");
			}else if(wm.getIsva().equals("5")){
				wm.setState("退货审核通过");
			}else if(wm.getIsva().equals("4")){
				wm.setState("退货等待审核");
			}else if(wm.getIsva().equals("5")){
				wm.setState("退货审核通过");
			}
			wm.setPfDates(Tools.SDF_TIME.format(wm.getPfDate()));
		}
		return list;
	}

	@Override
	public List<WholesaleModel> findLoginRows(WholesaleModel t) {
		// TODO Auto-generated method stub
		return wholesaleDao.findLoginRows(t);
	}
	/**
	 * 显示所有(批发退货)
	 */
	@Override
	public List<WholesaleModel> findAlls(Map<String, String> map) {
		List<WholesaleModel> list=wholesaleDao.findAlls(map);
		for(WholesaleModel wm:list){
			if(wm.getIsva().equals("4")){
				wm.setState("等待审核");
			}else if(wm.getIsva().equals("5")){
				wm.setState("审核通过");
			}else if(wm.getIsva().equals("3")){
				wm.setState("审核不通过");
			}
			wm.setPfDates(Tools.SDF_TIME.format(wm.getPfDate()));
		}
		return list;
	}
	/**
	 * 显示所有分页(批发退货)
	 */
	@Override
	public int findRows(Map<String, String> map) {
		// TODO Auto-generated method stub
		return wholesaleDao.findRows(map);
	}
	
	/**
	 * 批发退货 财务审核
	 */
	@Override
	public List<WholesaleModel> findAllPf(Map<String, String> map) {
		List<WholesaleModel> list=wholesaleDao.findAllPf(map);
		for(WholesaleModel wm:list){
			if(wm.getIsva().equals("4")){
				wm.setState("等待财务审核");
			}
			wm.setPfDates(Tools.SDF_TIME.format(wm.getPfDate()));
		}
		return list;
	}
	/**
	 * 批发退货 财务审核
	 */
	@Override
	public int findRowPf(Map<String, String> map) {
		// TODO Auto-generated method stub
		return wholesaleDao.findRowPf(map);
	}
	/**
	 * 根据批发Id修改审核状态(重新审核)
	 * @param pfId
	 * @return
	 */
	@Override
	public int updateByPfId(String pfId) {
		// TODO Auto-generated method stub
		return wholesaleDao.updateByPfId(pfId);
	}
	
}
